/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Utility;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
 *
 * @author c0909k1144
 */
public class DBProcess {

    public static void main(String[] args) {
        if (DBProcess.getConnection() != null) {
            System.out.println("Okkkkkkkkkkkkkkkkkkkkkkkkkkkk");
        }
    }

    public static Connection getConnection() {
        Connection conn = null;
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=RecruitmentProcessSystem", "sa", "1234567");
        } catch (SQLException ex) {
            Logger.getLogger(DBProcess.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(DBProcess.class.getName()).log(Level.SEVERE, null, ex);
        }
        return conn;
    }

    public static void closeConnection(Connection conn) {
        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException ex) {
                Logger.getLogger(DBProcess.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    public static void closeStatement(PreparedStatement stm) {
        if (stm != null) {
            try {
                stm.close();
            } catch (SQLException ex) {
                Logger.getLogger(DBProcess.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    public static void closeResultSet(ResultSet rs) {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException ex) {
                Logger.getLogger(DBProcess.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}
